In graph theory and theoretical computer science, the longest path problem is the problem of finding a simple path of maximum length in a given graph. A path is called simple if it does not have any repeated vertices; the length of a path may either be measured by its number of edges, or (in ) by the sum of the weights of its edges. In contrast to the shortest path problem, which can be solved in polynomial time in graphs without negative-weight cycles, the longest path problem is NP-hard and the decision version of the problem, which asks whether a path exists of at least some given length, is NP-complete. This means that the decision problem cannot be solved in polynomial time for arbitrary graphs unless P = NP. Stronger hardness results are also known showing that it is difficult to approximate. However, it has a linear time solution for directed acyclic graphs, which has important applications in finding the critical path in scheduling problems.
If the longest path problem could be solved in polynomial time, it could be used to solve this decision problem, by finding a longest path and then comparing its length to the number k. Therefore, the longest path problem is NP-hard. The question "does there exist a simple path in a given graph with at least k edges" is NP-complete..
In weighted with non-negative edge weights, the weighted longest path problem is the same as the Travelling salesman path problem, because the longest path always includes all vertices..
For most graphs, this transformation is not useful because it creates cycles of negative length in − G. But if G is a directed acyclic graph (DAG), then no negative cycles can be created, and a longest path in G can be found in linear time by applying a linear time algorithm for shortest paths in − G, which is also a directed acyclic graph.. For a DAG, the longest path from a source vertex to all other vertices can be obtained by running the shortest-path algorithm on − G.
Similarly, for each vertex v in a given DAG, the length of the longest path ending at v may be obtained by the following steps:
This is equivalent to running the shortest-path algorithm on − G.
Longest paths of directed acyclic graphs may also be applied in layered graph drawing: assigning each vertex v of a directed acyclic graph G to the layer whose number is the length of the longest path ending at v results in a layer assignment for G with the minimum possible number of layers..
write that the longest path problem in unweighted undirected graphs "is notorious for the difficulty of understanding its approximation hardness"..The best polynomial time approximation algorithm known for this case achieves only a very weak approximation ratio, .. For earlier work with even weaker approximation bounds, see and . For all , it is not possible to approximate the longest path to within a factor of unless NP is contained within Time complexity; however, there is a big gap between this inapproximability result and the known approximation algorithms for this problem..
In the case of unweighted but directed graphs, strong inapproximability results are known. For every the problem cannot be approximated to within a factor of unless P = NP, and with stronger complexity-theoretic assumptions it cannot be approximated to within a factor of . The color-coding technique can be used to find paths of logarithmic length, if they exist, but this gives an approximation ratio of only ..
For graphs of bounded clique-width, the longest path can also be solved by a polynomial time dynamic programming algorithm. However, the exponent of the polynomial depends on the clique-width of the graph, so this algorithms is not fixed-parameter tractable. The longest path problem, parameterized by clique-width, is hard for the parameterized complexity class , showing that a fixed-parameter tractable algorithm is unlikely to exist..
For the class of , an -time algorithm is known, which uses a dynamic programming approach.. This dynamic programming approach has been exploited to obtain polynomial-time algorithms on the greater classes of circular-arc graphs. and of co-comparability graphs (i.e. of the complement graph of comparability graphs, which also contain permutation graphs),. both having the same running time . The latter algorithm is based on special properties of the lexicographic depth first search (LDFS) vertex ordering. of co-comparability graphs. For co-comparability graphs also an alternative polynomial-time algorithm with higher running time is known, which is based on the Hasse diagram of the partially ordered set defined by the complement graph of the input co-comparability graph..
Furthermore, the longest path problem is solvable in polynomial time on any class of graphs with bounded treewidth or bounded clique-width, such as the distance-hereditary graphs. Finally, it is clearly NP-hard on all graph classes on which the Hamiltonian path problem is NP-hard, such as on , , and .
A simple model of a directed acyclic graph is the Price model, developed by Derek J. de Solla Price to represent Citation graph. This is simple enough to allow for analytic results to be found for some properties. For instance, the length of the longest path, from the n-th node added to the network to the first node in the network, scales as .
|
|